﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EzDesk.Attendance.Model
{
    /// <summary>
    /// 描述某一天的假期状况
    /// </summary>
    public class DayLeaveInfo
    {
        public DayLeaveInfo(DateTime date)
        {
            Date = date;
            IsWholeDay = false;
        }

        public DateTime Date { get; private set; }

        private IList<DayLeaveItemInfo> _leaves;

        /// <summary>
        /// 一天中所有的请假条目
        /// </summary>
        public IList<DayLeaveItemInfo> Leaves
        {
            get
            {
                if (_leaves == null)
                {
                    _leaves = new List<DayLeaveItemInfo>();
                }
                return _leaves;
            }
            set
            {
                _leaves = value;
            }
        }

        public DayLeaveItemInfo FirstLeave
        {
            get
            {
                return (Leaves != null && Leaves.Count > 0) ? Leaves.First() : null;
            }
        }

        public DayLeaveItemInfo LastLeave
        {
            get
            {
                return (Leaves != null && Leaves.Count > 0) ? Leaves.Last() : null;
            }
        }

        /// <summary>
        /// 全天放假
        /// </summary>
        public bool IsWholeDay { get; set; }
    }

    public class DayLeaveItemInfo
    {
        /// <summary>
        /// 假期名称
        /// </summary>
        public string LeaveName { get; set; }
        /// <summary>
        /// 假期Id
        /// </summary>
        public Guid LeaveId { get; set; }

        /// <summary>
        /// 日期
        /// </summary>
        public DateTime Day { get; set; }
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartTime { get; set; }
        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime EndTime { get; set; }
        /// <summary>
        /// 是否为工作假期
        /// </summary>
        public bool IsForWork { get; set; }

    }
}
